package com.xydtech.ecard.busi.controller;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.xydtech.common.EcardApiMiniProgramSendMsgService;
import com.xydtech.common.annotation.RsaRequest;
import com.xydtech.common.config.XydtechBusiPlatConfig;
import com.xydtech.common.core.domain.entity.SysDept;
import com.xydtech.common.core.domain.entity.SysUser;
import com.xydtech.common.enums.ResultStatus;
import com.xydtech.common.model.ResponseModel;
import com.xydtech.common.utils.StringUtils;
import com.xydtech.common.utils.file.FileUploadUtils;
import com.xydtech.common.utils.file.MimeTypeUtils;
import com.xydtech.data.DataPlatHttpUtils;
import com.xydtech.ecard.busi.domain.EcardApiEcardBusiReservation;
import com.xydtech.ecard.busi.service.IEcardApiEcardBusiReservationService;
import com.xydtech.ecard.config.domain.EcardGridManage;
import com.xydtech.ecard.config.service.IEcardGridManageService;
import com.xydtech.ecard.ecard.controller.EcardApiBaseController;
import com.xydtech.ecard.statistics.service.IEcardReportQueryService;
import com.xydtech.ecard.user.domain.EcardApiEcardRegistInfo;
import com.xydtech.ecard.user.domain.EcardApiUserInfo;
import com.xydtech.ecard.user.service.IEcardApiEcardRegistInfoService;
import com.xydtech.ecard.user.service.IEcardApiUserService;
import com.xydtech.system.domain.SysWechatApplet;
import com.xydtech.system.service.ISysConfigService;
import com.xydtech.system.service.ISysDeptService;
import com.xydtech.system.service.ISysUserService;
import com.xydtech.system.service.ISysWechatAppletService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.*;

/**
 * 业务预约登记Controller
 *
 * @author Daniel
 * @date 2021-09-06
 */
@Controller
@Api(tags = "电子名片-业务预约登记")
@RequestMapping("/ecardSaasApi/busi/reservation")
public class EcardApiEcardBusiReservationController extends EcardApiBaseController {

    private static final Logger logger = LoggerFactory.getLogger(EcardApiEcardBusiReservationController.class);

    @Autowired
    private ISysConfigService configService;
    @Autowired
    private IEcardApiEcardBusiReservationService busiReservationService;
    @Autowired
    private ISysDeptService deptService;
    @Autowired
    private ISysWechatAppletService wechatAppletService;
    @Autowired
    DataPlatHttpUtils dataPlatHttpUtils;
    @Autowired
    private EcardApiMiniProgramSendMsgService miniProgramSendMsgService;
    @Autowired
    private IEcardApiEcardRegistInfoService ecardRegistInfoService;
    @Autowired
    private IEcardReportQueryService ecardReportQueryService;
    @Autowired
    private IEcardApiUserService ecardApiUserService;
    @Autowired
    private IEcardGridManageService ecardGridManageService;
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private ISysDeptService sysDeptService;
    //文件分布式存储开关
    @Value("${busiplat.minioUpload}")
    private boolean minioUpload;
    @Value("${url.apiServiceUrl}")
    private String apiServiceUrl;

    /**
     * 电子名片-业务预约登记-预约提交
     *
     * @param busiReservation
     * @return
     */
    @PostMapping(value = "/submitReservation", consumes = "application/json")
    @ApiOperation(value = "电子名片-业务预约登记-预约提交", notes = "电子名片-业务预约登记-预约提交")
    @ApiImplicitParams({@ApiImplicitParam(name = "busiReservation", value = "预约内容", dataType = "com.xydtech.ecard.busi.domain.EcardApiEcardBusiReservation", paramType = "body", required = true)})
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    @RsaRequest(result = false)
    public ResponseModel submitReservation(@RequestBody @Validated EcardApiEcardBusiReservation busiReservation) {
        String salt = getSalt();//盐值
        /**
         * 思路：
         * 1. 首先查询下改用户对应的预约产品下是否有预约，如果有预约，直接提示已存在，不可重复预约
         * 2. 如果没有，可以继续
         */
        try {
            String currentUserId = getCurrentUserId();
            EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(currentUserId, salt);
            //当前小程序id
            SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
            String appId = wechatApplet.getAppid();
            //当前小程序对应的法人机构ID
            Long parentDeptId = wechatApplet.getDeptId();
            //获取当前登录人ID

            busiReservation.setRegistId(currentUserId);
            busiReservation.setSts("0");
            List<EcardApiEcardBusiReservation> busiReservationList = busiReservationService.getSubmitBusiReservation(busiReservation, salt);
        /*if (busiReservationList.size() > 0) {
            return ResponseModel.error("抱歉，您已存在该产品的未处理预约，请勿重复预约！");
        }*/
            //根据法人机构ID和网格编码(暂定为存在/社区编码)查询网格信息
            EcardGridManage ecardGridManage = new EcardGridManage();
            ecardGridManage.setDeptId(parentDeptId);
            ecardGridManage.setGridCode(busiReservation.getVillagCode());
            ecardGridManage.setSts("1");
            List<EcardGridManage> manageList = ecardGridManageService.selectEcardGridManageList(ecardGridManage);
            //判断是否存在网格信息，存在则重新赋值cmRegistId为网格内成员的随机值
            if (manageList != null && manageList.size() > 0) {
                int index = new Random().nextInt(manageList.size());
                //根据userId查询对应的regist_id
                SysUser sysUser = sysUserService.selectUserById(manageList.get(index).getUserId(), salt);
                EcardApiEcardRegistInfo registInfo = ecardRegistInfoService.selectEcardApiEcardRegistInfoByUserCode(sysUser.getUserCode(), salt);
                busiReservation.setCmRegistId(registInfo.getRegistId());
            }
            int saveCount = busiReservationService.submitReservation(busiReservation, salt);

            if (saveCount > 0) {
                /**
                 * 预约成功后发送推送消息
                 * 1. 需要根据busiReservation中的cmRegistId查询被预约的客户经理的openId用作发送消息的接收人
                 * 2. 获取模板ID
                 */
                //1. 需要根据busiReservation中的cmRegistId查询被预约的客户经理的openId用作发送消息的接收人
                Long cmRegistId = busiReservation.getCmRegistId();
                EcardApiEcardRegistInfo ecardRegistInfo = ecardRegistInfoService.selectEcardApiEcardRegistInfoByRegistId(cmRegistId, salt);
                //预约成功后发送推送消息
                miniProgramSendMsgService.sendBusiReservationMessage(appId, ecardRegistInfo.getWechatId(), busiReservation, apiServiceUrl);
                return ResponseModel.ok();
            } else {
                return ResponseModel.error("提交失败！");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseModel.error("请求失败，请联系管理员");
        }
    }


    /**
     * 电子名片-业务预约登记-获取客户已经预约过的第一条业务
     *
     * @return
     */
    @PostMapping("/getCustFirstReservation")
    @ApiOperation(value = "电子名片-业务预约登记-获取客户已经预约过的第一条业务", notes = "电子名片-业务预约登记-获取客户已经预约过的第一条业务")
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = EcardApiEcardBusiReservation.class)})
    @ResponseBody
    @RsaRequest(param = false)
    public ResponseModel getCustFirstReservation() {
        String salt = getSalt();//盐值
        String currentUserId = getCurrentUserId();
        EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(currentUserId, salt);
        //当前小程序id
        SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
        //当前小程序对应的法人机构ID
        List<EcardApiEcardBusiReservation> list = busiReservationService.getCustFirstReservation(currentUserId, wechatApplet.getDeptId(), salt);//字典机构查询条件
        return ResponseModel.okToJSONArray(list);
    }

    /**
     * 电子名片-业务预约登记-获取客户已经预约过的业务
     *
     * @return
     */
    @PostMapping("/getCustReservationList")
    @ApiOperation(value = "电子名片-业务预约登记-获取客户已经预约过的业务", notes = "电子名片-业务预约登记-获取客户已经预约过的业务")
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = EcardApiEcardBusiReservation.class)})
    @ResponseBody
    public ResponseModel getCustReservationList() {
        String salt = getSalt();//盐值
        String currentUserId = getCurrentUserId();
        EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(currentUserId, salt);
        //当前小程序id
        SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
        startPage();
        List<EcardApiEcardBusiReservation> list = busiReservationService.getCustReservationList(currentUserId, wechatApplet.getDeptId(), salt);
        return getTableResponse(list);
    }


    /**
     * 电子名片-首页-根据擅长业务查询对应的客户经理
     *
     * @param adeptPrdType
     * @return
     */
    @PostMapping("/getCustomerManagerByAdeptPrdType")
    @ApiOperation(value = "电子名片-首页-根据擅长业务查询对应的客户经理", notes = "电子名片-业务预约登记-根据擅长业务查询对应的客户经理")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "adeptPrdType", value = "擅长业务", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "coordinate", value = "所在位置", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = EcardApiEcardBusiReservation.class)})
    @ResponseBody
    public ResponseModel getCustomerManagerByAdeptPrdType(String adeptPrdType, String coordinate) {
        String salt = getSalt();//盐值
        List<EcardApiEcardRegistInfo> ecardRegistInfoList = new ArrayList<>();
        /**
         * 思路：
         * 1、 因客户经理的地理位置都是按照机构所在位置进行计算的，因此，先对机构进行距离计算和排序
         * 2、 然后查询客户经理按照机构的顺序进行排序
         */
        String currentUserId = getCurrentUserId();
        EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(currentUserId, salt);
        //当前小程序id
        SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
        String appId = wechatApplet.getAppid();

        if (StringUtils.isEmpty(appId)) {
            return ResponseModel.error(ResultStatus.PARAMETER_ERROR);
        }
        //小程序ID对应的父级机构ID
        Long parentDeptId = wechatApplet.getDeptId();

        SysDept sysDept = new SysDept();
        sysDept.setParentId(wechatApplet.getDeptId());
        sysDept.setDeptId(wechatApplet.getDeptId());
        List<SysDept> deptList = deptService.selectDeptList(sysDept, salt);

        //计算客户与支行之间的距离，2024-10-12修改，由于兖州查询慢，暂时先注释掉
        /*if (deptList.size() > 0 && StringUtils.isNotEmpty(coordinate)) {
            SysDept dept = sysDeptService.selectSecondLevelDeptByDeptId(parentDeptId);
            //腾讯地图请求地址
            String tencentMapUrl = configService.selectConfigByKey(ApiContant.TECENT_MAP_URL, dept.getDeptId());
            //腾讯地图请求Key
            String tencentMapKey = configService.selectConfigByKey(ApiContant.TECENT_MAP_KEY, dept.getDeptId());

            RestTemplate restTemplate = new RestTemplate();
            for (SysDept tempDept : deptList) {
                String cusmanagerCoordinate = tempDept.getCoordinate();
                if (cusmanagerCoordinate != null && StringUtils.isNotEmpty(cusmanagerCoordinate)) {
                    //TODO 内网部署需要修改
                    //String url = tencentMapUrl + "?mode=walking&from=" + coordinate + "&to=" + cusmanagerCoordinate + "&key=" + tencentMapKey;
                    //TencentMapDistance tencentMapDistance = restTemplate.getForObject(url, TencentMapDistance.class);
                    //if (tencentMapDistance.getStatus() == 0) {
                    //    Integer distance = tencentMapDistance.getResult().getRows().get(0).getElements().get(0).getDistance();
                    //    tempDept.setDistance((float) distance / 1000);
                    //}
                    if (coordinate.split(",").length == 2 && cusmanagerCoordinate.split(",").length == 2) {
                        double centerLon = Double.parseDouble(coordinate.split(",")[1]); //当前经度
                        double centerLat = Double.parseDouble(coordinate.split(",")[0]); //当前纬度
                        //机构经纬度
                        double targetLon = Double.parseDouble(cusmanagerCoordinate.split(",")[1]);
                        double targetLat = Double.parseDouble(cusmanagerCoordinate.split(",")[0]);
                        double distance = GeoUtil.distance(centerLon, centerLat, targetLon, targetLat);
                        tempDept.setDistance((float) distance / 1000);
                    }
                }
            }
            Collections.sort(deptList, new Comparator<SysDept>() {
                @Override
                public int compare(SysDept o1, SysDept o2) {
                    //判断是否为null
                    if (o1.getDistance() == null && o2.getDistance() == null) {
                        return 0;
                    }
                    if (o1.getDistance() == null) {
                        return 1;
                    }
                    if (o2.getDistance() == null) {
                        return -1;
                    }

                    Float diff = o1.getDistance() - o2.getDistance();

                    if (diff > 0) {
                        return 1;
                    } else if (diff <= 0) {
                        return -1;
                    }
                    return 0;
                }
            });

        }*/
        //然后按照机构的排序查询对应的客户经理
        startPage();
        ecardRegistInfoList = busiReservationService.getCustomerManagerByAdeptPrdType(adeptPrdType, deptList, parentDeptId);
        return getTableResponse(ecardRegistInfoList);
    }

    /**
     * 电子名片-业务预约登记-获取客户经理的业务预约列表
     *
     * @return
     */
    @PostMapping("/getReservationForManager/{sts}")
    @ApiOperation(value = "电子名片-业务预约登记-获取客户经理的业务预约列表", notes = "电子名片-业务预约登记-获取客户经理的业务预约列表")
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = EcardApiEcardBusiReservation.class)})
    @ResponseBody
    @RsaRequest(param = false)
    public ResponseModel getReservationForManager(@PathVariable("sts") String sts) {
        String salt = getSalt();//盐值
        //获取登录客户经理的信息
        String currentUserId = getCurrentUserId();

        startPage();
        List<EcardApiEcardBusiReservation> busiReservationList = busiReservationService.getReservationForManager(currentUserId, sts, salt);

        return ResponseModel.okToJSONArray(new PageInfo(busiReservationList).getTotal(), busiReservationList);
    }

    /**
     * 电子名片-业务预约登记-获取业务预约详情
     *
     * @return
     */
    @GetMapping("/getReservationDetail/{resId}")
    @ApiOperation(value = "电子名片-业务预约登记-获取业务预约详情", notes = "电子名片-业务预约登记-获取业务预约详情")
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = EcardApiEcardBusiReservation.class)})
    @ResponseBody
    @RsaRequest(param = false)
    public ResponseModel getReservationDetail(@PathVariable("resId") String resId) {
        if (StringUtils.isEmpty(resId)) {
            return ResponseModel.error(ResultStatus.PARAMETER_MISSING);
        }
        String salt = getSalt();//盐值
        EcardApiEcardBusiReservation busiReservation = busiReservationService.getReservationDetail(resId, salt);

        return ResponseModel.ok(JSONObject.toJSONString(busiReservation));
    }

    /**
     * 电子名片-业务预约登记-对预约业务无意向
     *
     * @return
     */
    @PostMapping("/noIntentionForReservation")
    @ApiOperation(value = "电子名片-业务预约登记-对预约业务无意向", notes = "电子名片-业务预约登记-对预约业务无意向")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "resId", value = "预约ID", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    public ResponseModel noIntentionForReservation(String resId) {
        if (StringUtils.isEmpty(resId)) {
            return ResponseModel.error(ResultStatus.PARAMETER_MISSING);
        }
        int count = busiReservationService.noIntentionForReservation(resId);
        return count > 0 ? ResponseModel.ok() : ResponseModel.error("操作失败！");
    }

    /**
     * 电子名片-业务预约登记-受理确认
     *
     * @return
     */
    @PostMapping("/acceptReservation")
    @ApiOperation(value = "电子名片-业务预约登记-受理确认", notes = "电子名片-业务预约登记-受理确认")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ecardBusiReservation", value = "受理确认对象", dataType = "EcardApiEcardBusiReservation", dataTypeClass = EcardApiEcardBusiReservation.class, paramType = "body", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    public ResponseModel acceptReservation(@RequestBody EcardApiEcardBusiReservation ecardBusiReservation) {
        int saveCount = busiReservationService.acceptReservation(ecardBusiReservation);
        return saveCount > 0 ? ResponseModel.ok() : ResponseModel.error("受理确认失败！");
    }

    /**
     * 电子名片-业务预约登记-生成初审报告
     *
     * @return
     */
    @PostMapping(value = "/generateFirstReviewReport", consumes = "application/json")
    @ApiOperation(value = "电子名片-业务预约登记-生成初审报告", notes = "电子名片-业务预约登记-生成初审报告")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "prdTarget", value = "产品目标:1-个人;2-企业", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "resId", value = "预约记录ID", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "phoneNumbers", value = "手机号码", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "name", value = "姓名", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "idCardNumber", value = "身份证号码", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    @RsaRequest(result = false)
    public ResponseModel generateFirstReviewReport(@RequestBody String json) {
        try {
            String salt = getSalt();//盐值
            if (StringUtils.isEmpty(json)) {
                return ResponseModel.error(ResultStatus.PARAMETER_MISSING);
            }
            String prdTarget = JSONObject.parseObject(json).getString("prdTarget");
            if (StringUtils.isEmpty(prdTarget)) {
                return ResponseModel.error("产品目标:" + ResultStatus.PARAMETER_MISSING.getMsg());
            }
            String phoneNumbers = JSONObject.parseObject(json).getString("phoneNumbers");
            if (StringUtils.isEmpty(phoneNumbers)) {
                return ResponseModel.error("手机号码:" + ResultStatus.PARAMETER_MISSING.getMsg());
            }
            String name = JSONObject.parseObject(json).getString("name");
            if (StringUtils.isEmpty(name)) {
                return ResponseModel.error("姓名:" + ResultStatus.PARAMETER_MISSING.getMsg());
            }
            String idCardNumber = JSONObject.parseObject(json).getString("idCardNumber");
            if (StringUtils.isEmpty(idCardNumber)) {
                return ResponseModel.error("身份证号码:" + ResultStatus.PARAMETER_MISSING.getMsg());
            }
            String resId = JSONObject.parseObject(json).getString("resId");
            if (StringUtils.isEmpty(resId)) {
                return ResponseModel.error("预约记录ID:" + ResultStatus.PARAMETER_MISSING.getMsg());
            }
            Map<String, Object> params = new HashMap<>();
            params.put("phoneNumbers", phoneNumbers);
            params.put("name", name);
            params.put("idCardNumber", idCardNumber);
            EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(getCurrentUserId(), salt);
            //当前小程序id
            SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
            String appId = wechatApplet.getAppid();
            JSONObject jsonUrl = ecardReportQueryService.createReport(appId, userInfo.getDeptId(), userInfo.getWechatName(), prdTarget, params);
            //PDF文件路径
            String pdfUrl = jsonUrl.getString("newPdfFile");
            //图片路径
            String viewPath = jsonUrl.getString("viewPath");

            //int updateCount = busiReservationService.updateReportUrl(resId, viewPath);
            EcardApiEcardBusiReservation reservation = new EcardApiEcardBusiReservation();
            reservation.setResId(Long.valueOf(resId));
            reservation.setReportUrl(viewPath);
            String pdfKey = "$.reportUrl";
            int updateCount = busiReservationService.updateEcardApiEcardBusiReservation(reservation, salt);
            busiReservationService.updatePdfReport(pdfKey, pdfUrl, resId);
            return updateCount > 0 ? ResponseModel.ok(viewPath) : ResponseModel.error("生成初审报告失败!");
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseModel.error("操作失败，请联系管理员");
        }
    }


    /**
     * 电子名片-业务预约登记-上传业务办理凭证
     *
     * @param resId
     * @param certImageFile
     * @return
     */
    @PostMapping("/uploadCertImage")
    @ApiOperation(value = "电子名片-业务预约登记-上传业务办理凭证", notes = "电子名片-业务预约登记-上传业务办理凭证")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "resId", value = "业务预约ID", dataType = "String", dataTypeClass = String.class, paramType = "body", required = true),
            @ApiImplicitParam(name = "certImageFile", value = "业务办理凭证", dataType = "MultipartFile", dataTypeClass = MultipartFile.class, paramType = "body", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    public ResponseModel uploadCertImage(@RequestParam("resId") String resId, @RequestParam("certImageFile") MultipartFile certImageFile) {
        try {
            String salt = getSalt();//盐值
            //获取当前小程序对应的法人机构
            String currentUserId = getCurrentUserId();
            EcardApiUserInfo userInfo = ecardApiUserService.getUserInfo(currentUserId, salt);
            //当前小程序id
            SysWechatApplet wechatApplet = getAppIdByDeptId(userInfo.getDeptId());
            //当前小程序对应的法人机构ID
            Long parentDeptId = wechatApplet.getDeptId();

            if (!certImageFile.isEmpty()) {
                //20230711 update 加入图片文件类型后缀判断
                String certImageFilePath = FileUploadUtils.uploadFileType(
                        XydtechBusiPlatConfig.getEcardFilePath() + "/" + parentDeptId + "/certImage", certImageFile, minioUpload, MimeTypeUtils.IMAGE_EXTENSION);
                int updateCount = busiReservationService.updateReservationCertImage(resId, certImageFilePath);
                return updateCount > 0 ? ResponseModel.ok(certImageFilePath) : ResponseModel.error("业务办理凭证文件上传失败！");
            } else {
                return ResponseModel.error("业务办理凭证文件不能为空！");
            }
        } catch (Exception e) {
            logger.error("业务办理凭证文件上传失败！", e);
            e.printStackTrace();
            return ResponseModel.error("上传办理凭证失败");
        }
    }

    /**
     * 电子名片-业务预约登记-业务转交
     *
     * @param resId
     * @param transToRegistId
     * @return
     */
    @PostMapping("/transReservation")
    @ApiOperation(value = "电子名片-业务预约登记-业务转交", notes = "电子名片-业务预约登记-业务转交")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "resId", value = "业务预约ID", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
            @ApiImplicitParam(name = "transToRegistId", value = "接收业务客户经理ID", dataType = "String", dataTypeClass = String.class, paramType = "query", required = true),
    })
    @ApiResponses({@ApiResponse(code = 0, message = "OK", response = ResponseModel.class)})
    @ResponseBody
    public ResponseModel transReservation(String resId, String transToRegistId) {

        String currentUserId = getCurrentUserId();
        //转交的时候，需要清空下业务预约中的报告信息，因为报告中有客户经理的姓名，所以防止转交之后，新的客户经理打开报告还是之前客户经理的名字
        int count = busiReservationService.transReservation(resId, currentUserId, transToRegistId);
        return count > 0 ? ResponseModel.ok() : ResponseModel.error("业务转交失败！");
    }
}
